package com.mikasa.springboot.example.rabbitmq.demo;

import com.mikasa.springboot.example.domain.User;
import com.mikasa.springboot.example.redismq.UserMessageListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by User on 17/1/16.
 */

@Component
public class Sender {

    private static final Logger LOGGER = LoggerFactory.getLogger(Sender.class);
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(String message) {
        LOGGER.info("Sender : " + message);
        rabbitTemplate.convertAndSend("hello", message);
    }

    public void send1(String message) {
        LOGGER.info("Sender1 : " + message);
        rabbitTemplate.convertAndSend("exchange", "topic.message", message);
    }

    public void send2(User user) {
        LOGGER.info("Sender2 : " + user);
        rabbitTemplate.convertAndSend("exchange", "topic.messages", user);
    }
}
